package com.fuqi.android.zhongcai.base.view.activity;


import android.util.Log;
import android.view.View;
import android.widget.EditText;

import com.android.volley.Response;
import com.android.volley.error.VolleyError;
import com.fuqi.android.zhongcai.R;
import com.fuqi.android.zhongcai.base.request.api.FeedBackApi;
import com.fuqi.android.zhongcai.base.request.result.FeedbackResult;
import com.fuqi.android.zhongcai.utils.ActivityUtils;
import com.fuqi.framework.network.code.HandleCode;
import com.fuqi.framework.network.http.RequestManager;

import butterknife.Bind;
import butterknife.OnClick;

public class FeedbackActivity extends BaseActivity {


    @Bind(R.id.et_qq)
    EditText etQQ;
    @Bind(R.id.et_feedback)
    EditText etFeedback;


    @OnClick(R.id.btn_submit)
    public void onClick(View view){

        String feedback = etFeedback.getText().toString().trim();
        String qqContact = etQQ.getText().toString().trim();

        if (feedback.equals("")){


            ActivityUtils.toast("请输入反馈建议");

        } else if (qqContact.equals("")){

            ActivityUtils.toast("请输入联系方式");

        }else {

            RequestManager.getInstance().call(new FeedBackApi(new FeedBackApi.FeedbackParams(feedback,
                    qqContact),
                    respOrderListener, errorListener));


        }


    }


    Response.Listener<FeedbackResult> respOrderListener = new Response.Listener<FeedbackResult>() {

        @Override
        public void onResponse(FeedbackResult response) {

            if (HandleCode.requestSuccess()) {

                ActivityUtils.toast("反馈成功");
                finish();

            } else {



            }
        }
    };


    Response.ErrorListener errorListener = new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {

            Log.i("juner", "juner  error.getMessage(): " + error.getMessage());

        }
    };


    @Override
    public void initView() {

    }

    @Override
    public void initListener() {

    }

    @Override
    public void initData() {
        titleBar.setTitle("反馈建议");

    }

    @Override
    public boolean hasTitleBar() {
        return true;
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_feedback;
    }
}
